package v1

import (
	"github.com/gin-gonic/gin"
	"guns-go/model/request"
	"guns-go/model/response"
	"guns-go/service"
)

// @Tags OnlineUser
// @Summary 在线用户分页查询
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysOnlineUserParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysOnlineUser/list [get]
func OnlineUserPage(c *gin.Context) {

	var U request.SysOnlineUserParam
	_ = c.ShouldBindQuery(&U)

	err, sysOnlineUserPageResult := service.OnlineUserPage(&U, c)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(sysOnlineUserPageResult, c)
}

// @Tags OnlineUser
// @Summary 在线用户强制下线
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysOnlineUserParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /sysOnlineUser/forceExist [post]
func OnlineUserForceExist(c *gin.Context) {

	var U request.SysOnlineUserParam
	_ = c.ShouldBindJSON(&U)

	err := service.OnlineUserForceExist(&U, c)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}

	response.Ok(c)
}
